scan() works like fold(), except that it emits all intermediate calculations. So, scan() emits downstream the initial value along with the result of each invocation of the supplied lambda expression.

You can learn more about this in:
Tags:
Run Edit